package ventottoGiuDuemilaundici;


public class HNode<E> {
	private int key;
	private E element; // element stored at this node
	private HNode<E> left, right, parent; // adjacent nodes

	/** Main constructor */
	public HNode(int key, E element, HNode<E> parent, HNode<E> left,
			HNode<E> right) {
		setKey(key);
		setElement(element);
		setParent(parent);
		setLeft(left);
		setRight(right);
	}

	/** Returns the key stored at this position */
	public int getKey() {
		return key;
	}
	
	/** Sets the key stored at this position */
	public void setKey(int k) {
		key = k;
	}
	
	/** Returns the element stored at this position */
	public E element() {
		return element;
	}

	/** Sets the element stored at this position */
	public void setElement(E o) {
		element = o;
	}

	/** Returns true if the left child isn't null */
	public boolean hasLeft() {
		if(left!=null) {
			return true;
		}
		return false;
		
	}
	
	/** Returns the left child of this position */
	public HNode<E> getLeft() {
		return left;
	}

	/** Sets the left child of this position */
	public void setLeft(HNode<E> v) {
		left = v;
	}
	
	/** Returns true if the right child isn't null */
	public boolean hasRight() {
		if(right!=null) {
			return true;
		}
		return false;
		
	}

	/** Returns the right child of this position */
	public HNode<E> getRight() {
		return right;
	}

	/** Sets the right child of this position */
	public void setRight(HNode<E> v) {
		right = v;
	}

	/** Returns the parent of this position */
	public HNode<E> getParent() {
		return parent;
	}

	/** Sets the parent of this position */
	public void setParent(HNode<E> v) {
		parent = v;
	}

}
